package FanShe.demo;

import java.util.Scanner;

public class zhebanchazhao {
    public static void main(String[] args) {
        int[] a={1,2,3,4,5,6,7,8,9,10};
        //1
        System.out.println("请输入你想查找的数");
        Scanner sc=new Scanner(System.in);
        int s= sc.nextInt();
        int flag=0;
        int left = 0;
        int right = a.length-1;

        while (left<=right){
            int i =(left+right)/2;
            if (a[i] == s){
                flag=1;
                System.out.println("找到了下标为"+i);
                break;
            }else if(a[i]<s){
                left = i + 1 ;
            }else {
                right = i - 1;
            }
        }
        if (flag == 0){
            System.out.println("找不到");
        }





//        for (int i=0 ; i<a.length ; i++){
//            if (a[i] != s ){
//                flag=1;
//            }else{
//                System.out.println("有 下标为"+ i );
//            }
//        }
//        if (flag==1){
//            System.out.println("不存在");
//        }







    }
}
